<extend name="Public/xbase"/>
<block name="style">
	<link rel="stylesheet" href="__PUBLIC__/admin/js/codemirror/codemirror.css">
	<link rel="stylesheet" href="__PUBLIC__/admin/js/codemirror/theme/{:C('codemirror_theme')}.css">
	<style>
		.CodeMirror,#preview_window{
			width:100%;
			height:500px;
		}
	</style>
</block>
<block name="body">
	<div class="main-title">
		<h2>编辑主题【{$theme}】</h2>
	</div>

	<div class="typecho-edit-theme">
		<div class="col-mb-12 col-tb-8 col-9 content" style="width:80%;float:left">
			<form action="{:addons_url('Theme://Theme/save')}" id="theme" name="theme" method="post" class="form-horizontal">
				<label class="sr-only" for="content">编辑源码</label>
				<label for="content">{$Think.FRONT_THEME_PATH}{$theme}/{$file|base64_decode}</label>
				<textarea class="w-100 mono" id="content" name="content">{$content}</textarea>
				<div class="controls">
					<input type="hidden" name="file" id="file" value="{$file|default=''}">
					<input type="hidden" name="name" id="name"  value="{$theme}">
					<div class="btn submit-btn" id="tsubmit">保存文件</div>
					<button target-form="form-horizontal" class="btn submit-btn ajax-post" type="submit" id="submit" style="display:none">保存文件</button>
					<a class="btn btn-return" href="{:U('index')}">返回主题列表</a>
				</div>
			</form>
		</div>
		<ul class="col-mb-12 col-tb-4 col-3" style="width:15%;float:left;padding-left:10px">
			<li><strong>模板文件</strong></li>
			<volist name="list" id="vo">
				<li>
				<a href="{:addons_url('Theme://Theme/edit',array('name'=>$theme, 'file'=>base64_encode($vo)))}">{$vo}</a>
				</li>
			</volist>
		</ul>
	</div>

</block>

<block name="script">
<script type="text/javascript" src="__PUBLIC__/admin/js/codemirror/codemirror.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/codemirror/xml.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/codemirror/javascript.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/codemirror/htmlmixed.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/codemirror/htmlembedded.js"></script>
	 <script>
			var codemirror_option = {
							lineNumbers   :true,
							matchBrackets :true,
							mode          :"application/x-httpd-php",
							indentUnit    :4,
							gutter        :true,
							fixedGutter   :true,
							indentWithTabs:true,
							readOnly	  :false,
							lineWrapping  :true,
							height		  :500,
							enterMode     :"keep",
							tabMode       :"shift",
							theme: "{:C('CODEMIRROR_THEME')}"
						};
      var editor = CodeMirror.fromTextArea(document.getElementById("content"), {
        lineNumbers: true,
       // mode          :"application/x-httpd-php",
		mode:"application/x-ejs",
        indentUnit: 4,
        indentWithTabs: true,
		theme: "{:C('CODEMIRROR_THEME')}"
      });
	//  alert(editor.getValue());
	  $("#tsubmit").click(function(){
		$("#content").val(editor.getValue());
		$("#submit").click();
		});
    </script>
</block>
